<?php
require_once("conn.php");
require_once("functions.php");
//echo "<pre>";
//print_r($config);
$sql = "select * from `link` where type = 2";
$row_user = $mysql->query($sql);
echo '微有趣注册系统暂时关闭';
die();
?>
<html>
<head>
    <meta charset="UTF-8">
    <title>微有趣</title>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <link rel="stylesheet" type="text/css" href="./assets/css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="./assets/css/zhuce.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script>
        function changeSize() {
            var propo = $(window).width() / 640;
            $('html').css('font-size', 40 * propo + 'px');
        }
        ;
        changeSize();
        $(window).resize(function () {
            changeSize();
        });
    </script>
    <script type="text/javascript">
    //判断注册端口 安卓，苹果，pc
    		var device = "";
			//判断苹果函数
			function isAppleMobileDevice(){
		   	 return (/iphone|ipod|ipad|Macintosh/i.test(navigator.userAgent.toLowerCase()));
			}
			var system ={
				win : false,
				mac : false,
				xll : false
				};
				//检测平台
				var p = navigator.platform;
				system.win = p.indexOf("Win") == 0;
				system.mac = p.indexOf("Mac") == 0;
//				system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
				//跳转语句，如果是手机访问就自动跳转到wap.baidu.com页面
			if(system.win||system.mac||system.x11){
			 	device = "pc";
			 	window.location.href = "http://<?php echo $row_user[0]['link']; ?>/weiApp/apple.php";
			}else{
				
				if(isAppleMobileDevice()){
			 		 device = "iphone";
			 	}else{
			 		 device = "android";
			 	}
			}
    
        var countdown = 60;
        function settime(obj) {
            if (countdown == 0) {
                obj.removeAttribute("disabled");
                obj.value = "再次获取验证码";
                countdown = 60;
                $("#yzm_btn").html(obj.value);
                return;
            } else {
                obj.setAttribute("disabled", true);
                obj.value = "重新发送(" + countdown + ")";
                countdown--;
                $("#yzm_btn").html(obj.value);
            }
            setTimeout(function () {
                    settime(obj)
                }
                , 1000)
        }
        //判断手机是否输入正确
        function is_phone() {
            var phone = $("#phone").val();
            if (phone && /^1[3|4|5|8]\d{9}$/.test(phone)) {
                $("#phone-span").html("");
                return true;
            } else {
                $("#phone-span").html("请输入正确手机号");
                return false;
            }
        }
        //验证码是否输入正确
        function is_yzm() {
            var yzm = $("#yzm_value").val();
            if (yzm && /^[0-9]*$/.test(yzm) && yzm.length == 6) {
                $("#yzm-span").html("");
                return true;
            } else {
                $("#yzm-span").html("验证码格式有误");
                return;
            }
        }
        //验证密码
        function is_password() {
            var password = $("#pwd").val();
            if (password == "") {
                $('#pwd-span').html("密码不能为空");
                return;
            } else if(password.length < 6 || password.length > 16){
                $("#pwd-span").html("密码不能小于6位或者大于16位");
                return;
            }else {
                $("#pwd-span").html("");
                return true;
            }
        }

        $(function () {
            //判断用户鼠标焦点
            $("#phone").blur(function () {
                is_phone();
            });
            $("#pwd").blur(function () {
                is_password();
            });
//            $("#repassword").blur(function () {
//                is_repassword();
//            })
            $("#yzm_value").blur(function () {
                is_yzm();
            })
            //发送验证码
            $("#yzm_btn").click(function () {
            
                var phone = $("#phone").val();
                var yzm_btn = this;
                if (is_phone()) {
                    var token = '<?php
                    $ip = GetIP()."CNM";
                    $token = md5($ip);
                    echo $token;
                    ?>';
                    $.get("regs.class.php", {phone: phone,ip:token}, function (data) {
                        $("#phone-span,#yzm-span").html("");
                        console.log(data);
                        if (data == 1) {
                            settime(yzm_btn);
                        } else if (data == 0) {
                            $("#phone-span").html("用户名已存在");
                        } else if (data == 3) {
                            $("#yzm-span").html("请在60秒后再次获取验证码");
                        } else {
//                      	alert($data);
                            $("#yzm-span").html("请稍后重试!");
                        }
                    })
                }
            });

            //拦截提交
            $("#regs_submit").click(function () {                             
                    var yzm_value = $("#yzm_value").val();
                    var phone = $("#phone").val();
                    var password = $("#pwd").val();
                    var tj_id = $("#tj_id").val();
//                    alert(phone + " " + password + " " + yzm_value + " " + tj_id);
                    if (is_phone() && is_yzm() && is_password()) {
                        setTimeout(function () {
                            $.post('regs.class.php', {
                            	device:device,
                                yzm_value: yzm_value,
                                tj_id: tj_id,
                                phone: phone,
                                password: password
                            }, function (data) {
//                                alert(data);
                                $("#phone-span,#yzm-span").html("");
                                if (data == 1) {
                                    
                                    alert("注册成功");
                                    window.location.href = "http://<?php echo $row_user[0]['link']; ?>/weiApp/download.php";
                                    window.jsObj.registSucceed(true);
                                    
                                }
                                if (data == 2) {
                                    $("#phone-span").html("用户名已存在");
                                }
                                if (data == 3) {
                                    $("#phone-span").html("注册失败,请稍后重试!");
                                }
                                if (data == 0) {
                                    $("#yzm-span").html("验证码错误");
                                }
                            })
                        }, 0)

                    }
                }
            )
        })
    </script>
</head>
<body>
	<div style="display: none;">
		<img src="http://<?php echo $row_user[0]['link']; ?>/weiApp/assets/images/zc/zc1.jpg"/>
	</div>	
<div class="wrap">
	<div class="user_id">
		ID：<?php echo $_GET['pid']?>
	</div>
    <div class="forms">
        <div class="pcl phone clearfix">
            <input id="tj_id" type="hidden" value="<?php
            $pid = isset($_GET['pid']) ? $_GET['pid'] : null;
            echo $pid;
            ?>">
            <input id="phone" type="tel" maxlength="11" placeholder="手机号"/>
            <span class="icon1"></span>
            <i id="phone-span"></i>
        </div>
        <div class="pcl code clearfix">
            <input id="yzm_value" maxlength="10" placeholder="请输入短信验证码"/>
            <span class="icon2"></span>
            <button id="yzm_btn" class="btncode">获取验证码</button>
            <a class="btncode2"><i id="second">60</i> s</a>
            <i id="yzm-span"></i>
        </div>
        <div class="pcl pwd clearfix">
            <input id="pwd" type="password" placeholder="请设置密码(6-20位字母或数字)"/>
            <span class="icon3"></span>
            <i id="pwd-span"></i>
        </div>
    </div>
    <div class="tk">
            <input type="checkbox" checked="checked"/>
        已阅读并同意【有妹纸】用户协议
    </div>
    <a id="regs_submit" class="reg">注册并领取红包</a>
    <a class="download">我已注册 立即下载</a>
</div>
<script type="text/javascript">
$(".download").click(function(){
	window.location.href = "http://<?php echo $row_user[0]['link']; ?>/weiApp/downloads.php";
})
	$(".tk").click(function(){
		window.location.href ="http://<?php echo $row_user[0]['link']; ?>/weiApp/agreement.html?id=<?php
            $pid = isset($_GET['id']) ? $_GET['id'] : null;
            echo $pid;
            ?>";
	})
</script>
</body>
</html>
